#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <stdexcept>

#include "BinaryTree.h"
#include "MyStack.h"

using namespace std;

using namespace MyStack;
using namespace BinaryTreeSp;

int compare(void *data1, void *data2)
{
    if ( (*(int* )data1) > (*(int* )data2)) {
        return 1;
    } else {
        return 0;
    }
}

int main(int argc, char **argv)
{
    int i;
    Stack myStack;

    i = 10;

    int dataValue = 0;
    while(i--)
    {
        myStack.push(dataValue);
        dataValue++;
    }

    i = 0;
    while(i<10) {
        dataValue = myStack.top();
        myStack.pop();
        cout << dataValue << " " << endl;
        i++;
    }
    
    int data[10] = {6, 2, 5, 7, 9, 3, 1, 4, 8, 10};

    BinaryTree * binaryTree = new BinaryTree(compare);
    for(int i=0; i<10; i++) {
        int *inData = new int;
        *inData = data[i];
        binaryTree->addData(inData);
    }

    cout << "PreOrderTraverse is :" << endl;
    binaryTree->preOrderTraverse(binaryTree->getRoot());
    cout << endl;

    cout << "InOrderTraverse is :" << endl;
    binaryTree->inOrderTraverse(binaryTree->getRoot());
    cout << endl;

    cout << "PostOrderTraverse is :" << endl;
    binaryTree->postOrderTraverse(binaryTree->getRoot());
    cout << endl;
}
